import request from '@/utils/request'

export default {
    namespace: 'home',
    state: {
        listData: []
    },
    effects: {
        *list({ payload, callback }, { call, put }) {
            const response = yield call(request, `/api/home-list?size=${payload}&limit=2`);
            yield put({ type: 'listData', payload: response, size: payload })
        }
    },
    reducers: {
        listData(state, { payload, size }) {
            console.log(size)
            if (size === 0) state.listData = [];
            const newData = state.listData.concat(payload)
            return {
                ...state,
                listData: newData
            }
        }
    }
}